﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Holiday List</title>
    <style type="text/css">
        body
        {
            font-size: 12px;
            font-family: "Lucida Grande" , Arial, "Trebuchet MS" , Verdana, sans-serif;
            padding: 1px 2px 2px 1px;
        }
        #tblMain
        {
            border-color: Green;
            border-style: solid;
        }
        #trHeader
        {
            background-color: Purple;
            vertical-align: middle;
        }
        #tblData
        {
            background-color: Olive;
        }
    </style>
</head>
<body onload="javascript:SetYears();">

    <script language="javascript" type="text/javascript">
        function SetYears() {
            var currentTime = new Date();
            var currentYr = currentTime.getFullYear();
            var ddlYr = document.getElementById('ddlYears');
            for (var i = 0; i < 6; i++) {
                ddlYr.options[ddlYr.options.length] = new Option(currentYr - 1 + i, currentYr - 1 + i);
            }
            ddlYr.selectedIndex = 1;
            document.getElementById('lblCurrentDate').innerHTML = currentTime.toDateString();
            GetHolidays();
        }

        function GetHolidays() {
            var ddlYr = document.getElementById("ddlYears");
            var selectedYr = ddlYr.options[ddlYr.selectedIndex].text;

            //New Year
            var dtNewYr = new Date();
            dtNewYr.setFullYear(selectedYr, 0, 1);
            if (dtNewYr.getDay() == 0)//if it is a sunday
                dtNewYr.setDate(dtNewYr.getDate() + 1);
            else if (dtNewYr.getDay() == 6)//if it is a saturday
                dtNewYr.setDate(dtNewYr.getDate() - 1);
            document.getElementById('lblNewYr').innerHTML = dtNewYr.toDateString();

            //Martin Luther King
            var dtLutherBDay = new Date();
            var dtActualNewYr = new Date();
            dtActualNewYr.setFullYear(selectedYr, 0, 1);
            dtLutherBDay.setFullYear(selectedYr, 0, GetMonday(2, dtActualNewYr.getDay()));
            document.getElementById('lblLutherBDay').innerHTML = dtLutherBDay.toDateString();


            //Washington BDay
            var dtWashingtonBDay = new Date();
            var firstDayofFeb = new Date();
            firstDayofFeb.setFullYear(selectedYr, 1, 1);
            dtWashingtonBDay.setFullYear(selectedYr, 1, GetMonday(2, firstDayofFeb.getDay()));
            document.getElementById('lblWashingtonBDay').innerHTML = dtWashingtonBDay.toDateString();

            //Memorial Day
            var dtMemorialDay = new Date();
            var lastDayofMay = new Date();
            lastDayofMay.setFullYear(selectedYr, 4, 31);
            dtMemorialDay.setFullYear(selectedYr, 4, GetLastMonday(lastDayofMay.getDay()));
            document.getElementById('lblMemorialDay').innerHTML = dtMemorialDay.toDateString();

            //Independence Day
            var dtIndependenceDay = new Date();
            dtIndependenceDay.setFullYear(selectedYr, 6, 4);
            if (dtIndependenceDay.getDay() == 0)//if it is a sunday
                dtIndependenceDay.setDate(dtIndependenceDay.getDate() + 1);
            else if (dtIndependenceDay.getDay() == 6)//if it is a saturday
                dtIndependenceDay.setDate(dtIndependenceDay.getDate() - 1);
            document.getElementById('lblIndependenceDay').innerHTML = dtIndependenceDay.toDateString();

            //Labor Day
            var dtLaborDay = new Date();
            var firstDayofSept = new Date();
            firstDayofSept.setFullYear(selectedYr, 8, 1);
            dtLaborDay.setFullYear(selectedYr, 8, GetMonday(0, firstDayofSept.getDay()));
            document.getElementById('lblLaborDay').innerHTML = dtLaborDay.toDateString();

            //Columbus Day
            var dtColumbusDay = new Date();
            var firstDayofOct = new Date();
            firstDayofOct.setFullYear(selectedYr, 9, 1);
            dtColumbusDay.setFullYear(selectedYr, 9, GetMonday(1, firstDayofOct.getDay()));
            document.getElementById('lblColumbusDay').innerHTML = dtColumbusDay.toDateString();

            //Veteran's Day
            var dtVeteransDay = new Date();
            dtVeteransDay.setFullYear(selectedYr, 10, 11);
            if (dtVeteransDay.getDay() == 0)//if it is a sunday
                dtVeteransDay.setDate(dtVeteransDay.getDate() + 1);
            else if (dtVeteransDay.getDay() == 6)//if it is a saturday
                dtVeteransDay.setDate(dtVeteransDay.getDate() - 1);
            document.getElementById('lblVeteransDay').innerHTML = dtVeteransDay.toDateString();

            //ThanksGiving
            var dtThanksGiving = new Date();
            var firstDayofNov = new Date();
            firstDayofNov.setFullYear(selectedYr, 10, 1);
            dtThanksGiving.setFullYear(selectedYr, 10, GetThursday(3, firstDayofNov.getDay()));
            document.getElementById('lblThanksgivingDay').innerHTML = dtThanksGiving.toDateString();

            //Christmas
            var dtChristmas = new Date();
            dtChristmas.setFullYear(selectedYr, 11, 25);
            if (dtChristmas.getDay() == 0)//if it is a sunday
                dtChristmas.setDate(dtChristmas.getDate() + 1);
            else if (dtChristmas.getDay() == 6)//if it is a saturday
                dtChristmas.setDate(dtChristmas.getDate() - 1);
            document.getElementById('lblChristmas').innerHTML = dtChristmas.toDateString();

            var currentDate = new Date();

            document.getElementById('lblDaysNewYr').innerHTML = days_between(currentDate, dtNewYr);
            document.getElementById('lblDaysLutherBDay').innerHTML = days_between(currentDate, dtLutherBDay);
            document.getElementById('lblDaysWashingtonBDay').innerHTML = days_between(currentDate, dtWashingtonBDay);
            document.getElementById('lblDaysMemorialDay').innerHTML = days_between(currentDate, dtMemorialDay);
            document.getElementById('lblDaysIndependenceDay').innerHTML = days_between(currentDate, dtIndependenceDay);
            document.getElementById('lblDaysLaborDay').innerHTML = days_between(currentDate, dtLaborDay);
            document.getElementById('lblDaysColumbusDay').innerHTML = days_between(currentDate, dtColumbusDay);
            document.getElementById('lblDaysVeteransDay').innerHTML = days_between(currentDate, dtVeteransDay);
            document.getElementById('lblDaysThanksgivingDay').innerHTML = days_between(currentDate, dtThanksGiving);
            document.getElementById('lblDaysChristmas').innerHTML = days_between(currentDate, dtChristmas);
        }

        function GetMonday(weekno, firstDayofMonth) {
            var retDay;
            if (firstDayofMonth == 0)//sunday
                return retDay = (weekno * 7) + 2; //16;
            else if (firstDayofMonth == 1)//monday
                return retDay = (weekno * 7) + 1; //15;
            else if (firstDayofMonth == 2)//tuesday
                return retDay = (weekno * 7) + 7; //21;
            else if (firstDayofMonth == 3)//wednesday
                return retDay = (weekno * 7) + 6; //20;
            else if (firstDayofMonth == 4)//thursday
                return retDay = (weekno * 7) + 5; //19;
            else if (firstDayofMonth == 5)//friday
                return retDay = (weekno * 7) + 4; //18;
            else if (firstDayofMonth == 6)//saturday
                return retDay = (weekno * 7) + 3; //17;
        }

        function GetLastMonday(lastDayofMay) {
            var retDay;
            if (lastDayofMay == 0)//sunday
                return retDay = 25;
            else if (lastDayofMay == 1)//monday
                return retDay = 31;
            else if (lastDayofMay == 2)//tuesday
                return retDay = 30;
            else if (lastDayofMay == 3)//wednesday
                return retDay = 29;
            else if (lastDayofMay == 4)//thursday
                return retDay = 28;
            else if (lastDayofMay == 5)//friday
                return retDay = 27;
            else if (lastDayofMay == 6)//saturday
                return retDay = 26;
        }

        function GetThursday(weekno, firstDayofMonth) {
            var retDay;
            if (firstDayofMonth == 0)//sunday
                return retDay = (weekno * 7) + 5;
            else if (firstDayofMonth == 1)//monday
                return retDay = (weekno * 7) + 4;
            else if (firstDayofMonth == 2)//tuesday
                return retDay = (weekno * 7) + 3;
            else if (firstDayofMonth == 3)//wednesday
                return retDay = (weekno * 7) + 2;
            else if (firstDayofMonth == 4)//thursday
                return retDay = (weekno * 7) + 1;
            else if (firstDayofMonth == 5)//friday
                return retDay = (weekno * 7) + 7;
            else if (firstDayofMonth == 6)//saturday
                return retDay = (weekno * 7) + 6;
        }

        function days_between(date1, date2) {
            var ONE_DAY = 1000 * 60 * 60 * 24; // The number of milliseconds in one day
            var date1_ms = date1.getTime(); // Convert both dates to milliseconds
            var date2_ms = date2.getTime();
            var difference_ms = Math.abs(date1_ms - date2_ms); // Calculate the difference in milliseconds
            var retText = "&nbsp;" + Math.round(difference_ms / ONE_DAY); // Convert back to days and return
            if (date1 > date2)
                return retText += "&nbsp;days past";
            else if (date1 == date2)
                return retText = "&nbsp;Today";
            else
                return retText += "&nbsp;days more";
        }
    </script>

    <form id="form1">
    <div>
        <table id="tblMain">
            <tr id="trHeader">
                <td align="center">
                    <b>Holiday List for&nbsp;</b>
                    <select id="ddlYears" onchange="javascript:GetHolidays();">
                    </select><br />
                    <label>
                        Today's Date&nbsp;</label><label style="font-weight: bold;" id="lblCurrentDate"></label>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <table id="tblData">
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/New_Year's_Day" target="_blank">New Year’s Day</a>
                            </td>
                            <td>
                                <label id="lblNewYr">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysNewYr">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Martin_Luther_King,_Jr._Day" target="_blank">Martin
                                    Luther King, Jr. Day</a>&nbsp;&nbsp;
                            </td>
                            <td>
                                <label id="lblLutherBDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysLutherBDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Washington's_Birthday" target="_blank">Washington’s
                                    Birthday</a>
                            </td>
                            <td>
                                <label id="lblWashingtonBDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysWashingtonBDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Memorial_Day" target="_blank">Memorial Day</a>
                            </td>
                            <td>
                                <label id="lblMemorialDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysMemorialDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Independence_Day_(US)" target="_blank">Independence
                                    Day</a>
                            </td>
                            <td>
                                <label id="lblIndependenceDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysIndependenceDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Labor_Day" target="_blank">Labor Day</a>
                            </td>
                            <td>
                                <label id="lblLaborDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysLaborDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Columbus_Day" target="_blank">Columbus Day</a>
                            </td>
                            <td>
                                <label id="lblColumbusDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysColumbusDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Veterans_Day" target="_blank">Veterans Day</a>
                            </td>
                            <td>
                                <label id="lblVeteransDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysVeteransDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Thanksgiving_(United_States)" target="_blank">
                                    Thanksgiving Day</a>
                            </td>
                            <td>
                                <label id="lblThanksgivingDay">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysThanksgivingDay">
                                </label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <a href="http://en.wikipedia.org/wiki/Christmas" target="_blank">Christmas</a>
                            </td>
                            <td>
                                <label id="lblChristmas">
                                </label>
                            </td>
                            <td>
                                <label id="lblDaysChristmas">
                                </label>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
